
#include <unistd.h>
#include <iostream>;

#include "input.h";
#include <SDL/SDL.h>;
#include <SDL/SDL_keysym.h>;

int mouseX;
int mouseY;

SDL_Event event;

bool leftClicked;
bool rightClicked;
bool leftPressed;
bool temp;
bool quit;

void pollEvents()
{
	
	while(SDL_PollEvent(&event))
	{
		if(event.type == SDL_MOUSEBUTTONUP && event.button.button == SDL_BUTTON_RIGHT)
		{
			rightClicked = true;
		}
		
		if(event.type == SDL_MOUSEBUTTONDOWN && event.button.button == SDL_BUTTON_LEFT)
		{
			leftPressed = true;
		}
		
		if(event.type == SDL_MOUSEBUTTONUP && event.button.button == SDL_BUTTON_LEFT)
		{
			leftClicked = true;
			leftPressed = false;
		}
		
		if(event.type == SDL_QUIT)
		{
			quit = true;
		}
	}
}

int getMouseX()
{
	SDL_PumpEvents();
	SDL_GetMouseState(&mouseX, &mouseY);
	return mouseX;
}

int getMouseY()
{
	SDL_PumpEvents();
	SDL_GetMouseState(&mouseX, &mouseY);
	return mouseY;
}

bool isLeftClicked()
{
	pollEvents();
	temp = leftClicked;
	leftClicked = false;
	return temp;
}


bool isRightClicked()
{
	pollEvents();
	temp = rightClicked;
	rightClicked = false;
	return temp;
}

bool isLeftPressed()
{
	pollEvents();
	return leftPressed;
}

bool isExitRequested()
{
	pollEvents();
	temp = quit;
	quit = false;
	return temp;
}

